<?php if(!defined('HDPHP_PATH'))exit;C('SHOW_NOTICE',FALSE);?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<link rel="stylesheet" href="http://127.0.0.1/hdwy/wasai/Public/Bootstrap/Css/bootstrap.min.css" />
	<link rel="stylesheet" href="http://127.0.0.1/hdwy/wasai/Application/Admin/View/Public/Css/common.css" />
	<script type="text/javascript" src='http://127.0.0.1/hdwy/wasai/Application/Admin/View/Public/Js/jquery-1.7.2.min.js'></script>
	<style type="text/css">
		body{
			margin-bottom: 100px;
		}
	</style>
		<script type="text/javascript" charset="utf-8">
			$(function(){
		      $('.add').change(function(){	
		      	var SpecArray = [];
		      	$.each($(".add"), function(k,v) {    
		      		SpecArray.push(v.value);                                                       
		      	});
				$.ajax({
					type:"post",
					url:"<?php echo U('getSpec');?>",
					data:{SpecArray : SpecArray},
			        dataType:'json',
			        success:function(phpData){
			        	if(phpData=='0'){
			        		alert('已有该组合属性,请重新选择 :)')
			        	}
			        }
				});
				
		      })
			 })
		</script>
</head>
<body>
	<div class="container-fluid">
	<div class="row-fluid">
	<div class="span12">

	
	<form action="<?php echo U('add');?>" method='post'>
	
		<table class='table table-bordered table-hover'>
			<tr>
				<th>货品ID</th>
				<?php foreach ($spec as $k=>$v){?>
					<th><?php echo $v['ta_name'];?></th>
				<?php }?>
				<th>库存</th>
				<th>货号</th>
				<th>操作</th>
			</tr>
			<?php foreach ($listData as $k=>$v){?>	
				<tr class="info">
					<td><?php echo $v['slid'];?></td>
				<?php foreach ($v['spec'] as $kk=>$vv){?>
					<td><?php echo $vv;?></td>
				<?php }?>
					<td><?php echo $v['inventory'];?></td>
					<td><?php echo $v['number'];?></td>
					<td>
						<a href="<?php echo U('edit',array('slid'=>$v['slid'],'tid'=>$_GET['tid']));?>" class="btn btn-warning"><i class="icon-pencil icon-white"></i>修改</a>
						<a href="<?php echo U('del',array('slid'=>$v['slid']));?>" class="btn btn-danger"><i class="icon-trash icon-white"></i>删除</a>
					</td>
				</tr>
			<?php }?>
			
			<tr class="info">
				<td>添加货品</td>		
			<?php foreach ($spec as $k=>$v){?>
				<td>
					<select name="spec[]" class="add">
						<option value="0">请选择</option>						
							<?php foreach ($v[option] as $kk=>$vv){?>
								<option value="<?php echo $vv['said'];?>"><?php echo $vv['savalue'];?></option>
							<?php }?>							
					</select>
				</td>
			<?php }?>
				<td>
					<input type="text" name='inventory' value="0" />				
				</td>
				<td>
					<input type="text" name='number' value="0" />
				</td>
				<td></td>
			</tr>
			
		</table>

		<input type="hidden" name='shop_sid' value='<?php echo $_GET["sid"];?>'/>
		<input type="hidden" name='type_tid' value='<?php echo $_GET["tid"];?>'/>
		<input type="submit" value='保存添加' class="btn btn-primary"/>
	</form>
	

	</div>
	</div>
	</div>


</body>
</html>